package cn.zch.soft.util.hutool.logistical;

import cn.hutool.core.lang.Console;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.Iterator;

/**
 * @author zchcpy
 * @描述 爱查快递 不准确
 */
public class Aichakuaidi{
    public static void main(String[] agrs){
        //2075704675
        //43271181412711779
        //9781802244504
        String id = "198277571961";
        aichakuaidi(id);
    }
    public static void aichakuaidi(String id){
        //https://biz.trace.ickd.cn/auto/9781802244504?mailNo=9781802244504&spellName=&exp-textName=&ts=123456&enMailNo=123456789&callback=_jqjsp&_1521178991970=
        String urlStr = String.format("https://biz.trace.ickd.cn/auto/%s",id);
        Console.log(urlStr);
        HttpResponse response = HttpRequest.get(urlStr).execute();
        String body = response.body();
        Console.log(body);
        JSONObject json2 = JSONObject.fromObject(body);
        Console.log("响应data内容=2" + json2);
        Iterator iterator = json2.keys();
        while(iterator.hasNext()){
            String key = (String)iterator.next();
            String value = json2.getString(key);
            Console.log(key + " " + value);
        }
        Console.log("****************************************");
        JSONArray json3 = JSONArray.fromObject(json2.get("data"));
        Iterator iterator2 = json3.iterator();
        while(iterator2.hasNext()){
            Console.log(iterator2.next());
        }
    }
}
